#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int i = 0;
    int j = 0;
    int arr[1000][1000];
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }

    int k = 0;
    scanf("%d", &k);
    int y = 0;
    for (y = 0; y < k; y++)
    {
        char t = '0';
        int a, b;
        scanf("%c %d %d", &t, &a, &b);
        if (t == 'r')
        {
            for (i = 0; i < m; i++)
            {
                int tmp = 0;
                tmp = arr[a][i];
                arr[a][i] = arr[b][i];
                arr[b][i] = tmp;
            }

        }
        if (t == 'c')
        {
            for (i = 0; i < n; i++)
            {
                int tmp = 0;
                tmp = arr[i][a];
                arr[i][a] = arr[i][b];
                arr[i][b] = arr[i][a];
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }


    return 0;
}